<?php
class Messages 
{
  private $_messages = array();
  function __construct( $messages ) {
    $this->_messages = $messages;
  }
  
  function init( &$smarty ) {
    $empty = array();
    $smarty->assignByRef('messages', $empty);
  }
  
  public function add( $code, &$smarty ) {
    if( isset( $this->_messages[$code] ) )
      $smarty->appendByRef('messages', $this->_messages[$code], true);
    else
      $smarty->appendByRef('messages', $this->_messages['E_DEFAULT'], true);
  }
}

?>